import React, {PureComponent} from 'react';
import styles from './index.less';
import {Table}  from 'antd';
import {Link} from 'dva/router';
class DistributeCountReportList extends PureComponent {

    handleEditRow = (record, pagination) => {
        this.props.onEditRow(record, pagination);
    }

    handleDelRow = (brand_id, pagination) => {
        this.props.onDelRow(brand_id, pagination);
    }

    handleOrderListChange = (pagination) => {
        this.props.onChange(pagination);
    }

    render(){

        const {data: {list, pagination}, loading,formValue} = this.props;
        const columns = [
            {
                title: '店铺名称', dataIndex: 'shop_name',fixed: 'left',
                render: (val, record) => {
                    return <span>{val}</span>
                }
            },
            {
                title: '分销商名称', dataIndex: 'nick_name',
                render: (val, record) => {
                    return <span><Link to={{pathname:'/distributorManage/order-report',
                        state:{shop_id:record.shop_id,
                            add_time:formValue.add_time,
                            nick_name:formValue.nick_name,
                            order_status:formValue.order_status,
                            pay_status:formValue.pay_status,
                            shipping_status:formValue.shipping_status,
                            timeType:formValue.timeType,
                        }}}>
                        {val}</Link></span>
                }
            },
            {
                title: '订单数', dataIndex: 'orderAmount',
                render: (val, record) => {
                    return <span>{val}</span>
                }
            },
            {
                title: '订单总金额', dataIndex: 'totalGoodsAmount',
                render: (val, record) => {
                    return  <span>{val}</span>
                }
            },
            {
                title: '订单销售商品总数量', dataIndex: 'totalGoodsNum',
                render: (val, record) => {
                    return <span><Link to={{pathname:'/distributorManage/count-report-goods',state:{shop_id:record.shop_id,
                        add_time:formValue.add_time,
                        nick_name:formValue.nick_name,
                        order_status:formValue.order_status,
                        pay_status:formValue.pay_status,
                        shipping_status:formValue.shipping_status,
                        timeType:formValue.timeType,}}}>{val}</Link></span>
                }
            },
            {
                title: '订单商品总成本价', dataIndex: 'totalCostPrice',
                render: (val, record) => {
                    return <span>{val}</span>
                }
            },

            {
                title: '佣金', dataIndex: 'commission',//是否在前台页面显示 1显示; 0不显示
                render: (val, record) => {
                    return <span>{record.totalGoodsAmount-record.totalCostPrice}</span>
                }
            },
            // {
            //     title: '操作',
            //     // fixed:'right',
            //     render: (val, record) => (
            //         <p>
            //             <a href="javascript:" onClick={() => this.handleEditRow(record, pagination)}>编辑</a>
            //             <span className={styles.splitLine}/>
            //             <Popconfirm title="是否确定删除?" onConfirm={() => this.handleDelRow(record.brand_id, pagination)} >
            //                 <a href="#">删除</a>
            //             </Popconfirm>
            //         </p>
            //     ),
            // },
        ];

        const paginationProps = {
            showSizeChanger: true,
            showQuickJumper: true,
            ...pagination,
        };
        return (
            <div className={styles.standardTable}>
                <Table
                    oading={loading}
                    rowKey={record => record.cat_id}
                    dataSource={list}
                    columns={columns}
                    onChange={this.handleOrderListChange}
                    pagination={paginationProps}
                />
            </div>
        )

    }
}
export default DistributeCountReportList;

